namespace YamltoMssql
{
    using System;
    using System.Xml.Serialization;
    
    [Serializable]
    [XmlRoot("mapping")]
    public struct Mapping
    {
        [XmlAttribute("version")]
        public int Version { get; set; }
        [XmlArray("tables")]
        public TableMapping[] Tables { get; set; }
    }

    [Serializable]
    [XmlType("table")]
    public struct TableMapping
    {
        [XmlAttribute("name")]
        public string Table { get; set; }
        [XmlArray("columns")]
        public ColumnMapping[] Columns { get; set; }
    }

    [Serializable]
    [XmlType("column")]
    public struct ColumnMapping
    {
        [XmlAttribute("name")]
        public string ColumnName { get; set; }
        [XmlAttribute("property")]
        public string PropertyName { get; set; }
        [XmlAttribute("type")]
        public string Type { get; set; }
        [XmlAttribute("nullable")]
        public bool IsNullable { get; set; }
        [XmlIgnore]
        public Type NativeType
        {
            get
            {
                return System.Type.GetType(this.Type, false, true);
            }
        }
    }
}